package com.eds.mall.ware.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eds.common.utils.PageUtils;
import com.eds.common.utils.Query;

import com.eds.mall.ware.dao.WareInfoDao;
import com.eds.mall.ware.entity.WareInfoEntity;
import com.eds.mall.ware.service.WareInfoService;
import org.springframework.util.StringUtils;


@Service("wareInfoService")
public class WareInfoServiceImpl extends ServiceImpl<WareInfoDao, WareInfoEntity> implements WareInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<WareInfoEntity> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(params.get("key"))) {
            wrapper.and(obj -> {
                obj.eq("id", params.get("key")).or().like("name", params.get("key"))
                        .or().like("address", params.get("key"))
                        .or().like("areacode", params.get("key"));
            });
        }

        IPage<WareInfoEntity> page = this.page(new Query<WareInfoEntity>().getPage(params), wrapper);

        return new PageUtils(page);
    }

}